use crate::gui;
use crate::trayicon;
use crate::window_state::WindowState;

use once_cell::sync::Lazy;
use std::sync::Arc;
use std::sync::Mutex; // Also need this for Mutex // Add this line

// 使用Arc来共享窗口状态
static WINDOW_STATE: Lazy<Arc<Mutex<WindowState>>> =
    Lazy::new(|| Arc::new(Mutex::new(WindowState { show: true })));



pub fn run() -> Result<(), Box<dyn std::error::Error>> {    
    // 初始化托盘图标管理器
    let _tray_manager = trayicon::TrayIconManager::new(WINDOW_STATE.clone())?;

    // 初始化并运行GUI
    let gui_manager = gui::GuiManager::new(WINDOW_STATE.clone());
    gui_manager.run();

    Ok(())
}